🌎 rns.kin.earth git 🌍
RNS/Cryptography/Hashes.py 4ece3a61401507ebeeff7eb7fb341b04835d7c1d (4ece3a61) Text, 1.89 KB
T8b949e# MIT License
T8b949e#
T8b949e# Copyright (c) 2022-2025 Mark Qvist / unsigned.io
T8b949e#
T8b949e# Permission is hereby granted, free of charge, to any person obtaining a copy
T8b949e# of this software and associated documentation files (the "Software"), to deal
T8b949e# in the Software without restriction, including without limitation the rights
T8b949e# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
T8b949e# copies of the Software, and to permit persons to whom the Software is
T8b949e# furnished to do so, subject to the following conditions:
T8b949e#
T8b949e# The above copyright notice and this permission notice shall be included in all
T8b949e# copies or substantial portions of the Software.
T8b949e#
T8b949e# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
T8b949e# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
T8b949e# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
T8b949e# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
T8b949e# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
T8b949e# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
T8b949e# SOFTWARE.
Tff7b72import T7ee787importlib
Tff7b72if Te6edf3importlibTff7b72.Td2a8ffutilTff7b72.Td2a8fffind_specTb4b4b4(Ta5d6ff'Ta5d6ffhashlibTa5d6ff'Tb4b4b4) Tff7b72!= Tff7b72NoneTb4b4b4:
Tff7b72import T7ee787hashlib
Tff7b72elseTb4b4b4:
Te6edf3hashlib Tff7b72= Tff7b72None
Tff7b72if Tffa657hasattrTb4b4b4(Te6edf3hashlibTb4b4b4, Ta5d6ff"Ta5d6ffsha512Ta5d6ff"Tb4b4b4)Tb4b4b4:
Tff7b72from T7ee787hashlib Tff7b72import Te6edf3sha512 Tff7b72as Te6edf3ext_sha512
Tff7b72elseTb4b4b4:
Tff7b72from T7ee787.T7ee787SHA512 Tff7b72import Te6edf3sha512 Tff7b72as Te6edf3ext_sha512
Tff7b72if Tffa657hasattrTb4b4b4(Te6edf3hashlibTb4b4b4, Ta5d6ff"Ta5d6ffsha256Ta5d6ff"Tb4b4b4)Tb4b4b4:
Tff7b72from T7ee787hashlib Tff7b72import Te6edf3sha256 Tff7b72as Te6edf3ext_sha256
Tff7b72elseTb4b4b4:
Tff7b72from T7ee787.T7ee787SHA256 Tff7b72import Te6edf3sha256 Tff7b72as Te6edf3ext_sha256
T8b949e"""
The SHA primitives are abstracted here to allow platform-
aware hardware acceleration in the future. Currently only
uses Python's internal SHA-256 implementation. All SHA-256
calls in RNS end up here.
"""
Tff7b72def Td2a8ffsha256Tb4b4b4(Te6edf3dataTb4b4b4)Tb4b4b4:
Te6edf3digest Tff7b72= Te6edf3ext_sha256Tb4b4b4(Tb4b4b4)
Te6edf3digestTff7b72.Td2a8ffupdateTb4b4b4(Te6edf3dataTb4b4b4)
Tff7b72return Te6edf3digestTff7b72.Td2a8ffdigestTb4b4b4(Tb4b4b4)
Tff7b72def Td2a8ffsha512Tb4b4b4(Te6edf3dataTb4b4b4)Tb4b4b4:
Te6edf3digest Tff7b72= Te6edf3ext_sha512Tb4b4b4(Tb4b4b4)
Te6edf3digestTff7b72.Td2a8ffupdateTb4b4b4(Te6edf3dataTb4b4b4)
Tff7b72return Te6edf3digestTff7b72.Td2a8ffdigestTb4b4b4(Tb4b4b4)
Served by rngit 1.5.2 - Generated in 0.03s